//
//  GDWaterFallBuilder.m
//  Gunterapple
//
//  Created by 热带雨林 on 2021/1/31.
//  Copyright © 2021 热带雨林. All rights reserved.
//

#import "GDWaterFallBuilder.h"
#import "calculateScale.h"
#import <CoreGraphics/CoreGraphics.h>

@implementation GDWaterFallBuilder

+ (NSArray *)generateSizesWithScales:(NSArray<NSNumber *> *)input{
    NSInteger count = input.count;
    
    float arr[count];
    float *p = arr;
    
    [input enumerateObjectsUsingBlock:
     ^(NSNumber * _Nonnull obj,
       NSUInteger idx, BOOL * _Nonnull stop) {
         
        *(p + idx) = obj.floatValue;
    }];
    
    calculate_scale(arr, (int)count);
    
    NSMutableArray *result = [NSMutableArray arrayWithCapacity:count];
    for (int i=0; i<count; i++) {
        CGSize scaleSize = CGSizeMake(arr[i], arr[i]/[input[i] floatValue]);
        [result addObject:@(scaleSize)];
    }
    return result;
}



@end
